package com.rc.saas.tenant.controller.member;

import com.alibaba.excel.EasyExcel;
import com.github.pagehelper.PageInfo;
import com.rc.saas.tenant.base.WebPageInfo;
import com.rc.saas.tenant.common.vo.TResponse;
import com.rc.saas.tenant.component.UploadComponent;
import com.rc.saas.tenant.component.UploadImg;
import com.rc.saas.tenant.model.member.RcMemberGainGradeSetting;
import com.rc.saas.tenant.model.member.RcMemberGainGradeSettingExample;
import com.rc.saas.tenant.model.member.RcMemberGainSetting;
import com.rc.saas.tenant.model.tenant.TenantUser;
import com.rc.saas.tenant.search.ticket.TicketSearch;
import com.rc.saas.tenant.service.member.MemeberLevelService;
import com.rc.saas.tenant.service.member.RcMemberGainGradeSettingService;
import com.rc.saas.tenant.service.member.RcMemberGainSettingService;
import com.rc.saas.tenant.service.ticket.TenantTicketTypeService;
import com.rc.saas.tenant.shiro.ShiroUtils;
import com.rc.saas.tenant.vo.ticket.TicketVo;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.net.URLEncoder;
import java.util.Date;
import java.util.List;

@Controller
@RequestMapping("/member/equity")
public class MemberSettingController {
    private static Logger logger = LogManager.getLogger(MemberSettingController.class);

    private String prefix = "/templates/member/member";


    @Autowired
    private RcMemberGainGradeSettingService memberGainGradeSettingService;

    @RequestMapping("/index")
    public String index(Model model) {
        RcMemberGainGradeSettingExample example = new RcMemberGainGradeSettingExample();
        List<RcMemberGainGradeSetting> infos = memberGainGradeSettingService.selectByExample(example);
        model.addAttribute("infos",infos);
        model.addAttribute("infoSize",infos.size());
        return prefix + "/equity";
    }

    @ResponseBody
    @RequestMapping("/saveSetting")
    public TResponse saveSetting(RcMemberGainGradeSetting setting) {
        TenantUser user = ShiroUtils.getSessionUser();
        memberGainGradeSettingService.saveSetting(setting,user);
        return TResponse.SUCCESS();
    }

}
